import request from './request'

import type {
  BaseRes,
  captchaRes,
  LoginParams,
  LoginRes,
  UserInfoRes,
  UserMenuListRes
} from '../types/types'




// 验证码接口
export const getCaptchaApi = () => {
    return request.get<BaseRes<captchaRes>>('login/captcha')
}

// 登录接口
export const loginApi = (params: LoginParams) => {
    return request.post<BaseRes<LoginRes>>('/login', params )
}
// 退出登录
export const logoutApi = () => {
    return request.post<BaseRes<null>>('/user/logout')
}


// 个人信息接口
export const getUserInfoApi = () => {
    return request.get<BaseRes<UserInfoRes>>('/user/info')
}

// 当前用户可访问的菜单
export const getMenuListApi = () => {
    return request.get<BaseRes<UserMenuListRes>>('/user/menulist')
}

// 用户列表接口
export const getUserListApi = (params: {page:number,pagesize:number}) => {
  return request.get<BaseRes<UserMenuListRes>>('/user/list',{
    params
  })
}